package com.qf.android.huihui.adapter.shopping;

import android.content.Context;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;

import com.bumptech.glide.Glide;
import com.bumptech.glide.load.engine.DiskCacheStrategy;
import com.qf.android.huihui.R;
import com.qf.android.huihui.bean.show.shoppingbottom.ShoppingBottomBean;

import java.util.List;

/**
 * Created by 韩爽 on 2017/1/13.
 */

public class ShoppingTopicGroupAdapter extends RecyclerView.Adapter<ShoppingTopicGroupAdapter.MyHolder> {
    private List<ShoppingBottomBean.DataBean.ListBeanXX.TopicGroupBean.ListBeanX> list;
    private Context context;

    public ShoppingTopicGroupAdapter(List<ShoppingBottomBean.DataBean.ListBeanXX.TopicGroupBean.ListBeanX> list, Context context) {
        this.list = list;
        this.context = context;
    }

    @Override
    public MyHolder onCreateViewHolder(ViewGroup parent, int viewType) {
        View view= LayoutInflater.from(context).inflate(R.layout.fragment_shopping_topicgroup_item,parent,false);
        MyHolder myHolder=new MyHolder(view);
        return myHolder;
    }

    @Override
    public void onBindViewHolder(MyHolder holder, int position) {
        ShoppingBottomBean.DataBean.ListBeanXX.TopicGroupBean.ListBeanX bean = list.get(position);
        Glide.with(context).load(bean.getImageUrl()).skipMemoryCache(true).diskCacheStrategy(DiskCacheStrategy.ALL).into(holder.imageView);
        holder.textView_content.setText(bean.getTitle());
        holder.textView_price_1.setText(bean.getPrice());
        holder.textView_price_2.setText(bean.getSubPrice());
    }

    @Override
    public int getItemCount() {
        return list.size();
    }

    public class MyHolder extends RecyclerView.ViewHolder {
        private ImageView imageView;
        private TextView textView_content;
        private TextView textView_price_1;
        private TextView textView_price_2;
        public MyHolder(View itemView) {
            super(itemView);
            imageView= (ImageView) itemView.findViewById(R.id.topicgroup_item_include).findViewById(R.id.hot_item_imageview);
            textView_content= (TextView) itemView.findViewById(R.id.topicgroup_item_include).findViewById(R.id.hot_item_title);
            textView_price_1= (TextView) itemView.findViewById(R.id.topicgroup_item_include).findViewById(R.id.hot_item_price_1);
            textView_price_2= (TextView) itemView.findViewById(R.id.topicgroup_item_include).findViewById(R.id.hot_item_price_2);
        }
    }
}
